package com.journey.org.ui.home.bilivideo.page

import android.app.Application
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableInt
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.journey.org.BR
import com.journey.org.R
import com.journey.org.ui.home.HomePagerItemViewModel
import com.mvvmhabit.org.base.BaseViewModel
import com.mvvmhabit.org.binding.command.BindingAction
import com.mvvmhabit.org.binding.command.BindingCommand
import com.mvvmhabit.org.bus.event.SingleLiveEvent
import me.tatarka.bindingcollectionadapter2.ItemBinding

/**
 * @Date: 2021/5/27 16:17
 * @Author:小妖
 * @Description: B站首页
 */
class BiliPageViewModel(application: Application) : BaseViewModel(application) {

    val requestStateField = ObservableInt()

    /**************************************** viewPager ***********************************/
    val onPagerLengthEvent = SingleLiveEvent<Int>()
    val pagerItemBinding =
        ItemBinding.of<BiliPagePagerViewItemModel>(BR.viewModel, R.layout.bili_page_pager_item)

    val pagerItems = ObservableArrayList<BiliPagePagerViewItemModel>()


    val onClickLoadMoreCommand = BindingCommand<Any>(object : BindingAction {
        override fun call() {

        }
    })

    val onClickRefreshCommand = BindingCommand<Any>(object : BindingAction {
        override fun call() {

        }
    })

    val onClickAgainLoadCommand = BindingCommand<Any>(object : BindingAction {
        override fun call() {

        }
    })

    val verticalManager = GridLayoutManager(application, 2, LinearLayoutManager.VERTICAL, false)

    val itemBinding = ItemBinding.of<BiliPageViewItemModel>(BR.viewModel, R.layout.bili_page_item)

    val items = ObservableArrayList<BiliPageViewItemModel>()

}